﻿/*
 
Celerity: Sensory Overload
Copright 2012 by Adam Hill, David Gannon, Thomas Tamblyn & Patrick Ytting
Contact: adam.hill@outlook.com
Website: adamhill.org
Licence: MS-Pl Licence
  
 */

using System;
using Celerity.Content;
using Celerity.Data;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Audio;

namespace Celerity.UI
{
    public partial class UILayer
    {
        public void Load(GraphicsDevice GraphicsDevice, SpriteBatch spriteBatch, ContentManager Content)
        {
            this.spriteBatch = spriteBatch;
            ImageLibrary.Load(GraphicsDevice);
            FontLibrary.Load(Content);
            controls.Load(coords);
            WireControlEvents();
        }

        public void WireControlEvents()
        {
            // IconBack
            controls.Items[(int)UIControl.IconBack].OnClicked += (s, e) =>
            {
                GlobalGameStates.GameState = GameState.Menu;
                GlobalGameStates.MenuState = MenuState.MainMenu;
                logic.OnUIClick();
            };

            // IconMute
            controls.Items[(int)UIControl.IconMute].OnClicked += (s, e) =>
            {
                GlobalGameStates.MuteState =
                    GlobalGameStates.MuteState == MuteState.Muted
                                                 ? MuteState.NotMuted
                                                 : MuteState.Muted;
                logic.OnUIClick();
            };

            // IconClose
            controls.Items[(int)UIControl.IconClose].OnClicked += (s, e) =>
            {
                if (OnClose != null)
                {
                    OnClose(this, new EventArgs());
                }
                logic.OnUIClick();
            };

            // PanelStart
            controls.Items[(int)UIControl.PanelStart].OnClicked += (s, e) =>
            {
                logic.OnStartGame();
            };

            // PopupGameOver
            controls.Items[(int)UIControl.PopupGameOver].OnClicked += (s, e) =>
            {
                logic.OnBack();
            };

            // Camera Fast
            controls.Items[(int)UIControl.PopupCameraFpsFast].OnClicked += (s, e) =>
            {
                logic.OnSetCameraFpsHigh();
            };

            // Camera Slow
            controls.Items[(int)UIControl.PopupCameraFpsSlow].OnClicked += (s, e) =>
            {
                logic.OnSetCameraFpsLow();
            };

            // Camera Override
            controls.Items[(int)UIControl.PopupCameraFpsOverride].OnClicked += (s, e) =>
            {
                logic.OnSetCameraFpsNever();
            };
        }
    }
}
